package com.mes.inventory.domain;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;
import org.hibernate.annotations.OrderBy;
import org.springframework.context.annotation.Lazy;

import com.mes.basicdata.domain.Employee;
import com.mes.basicdata.domain.TypesData;
import com.mes.common.domain.BasicModel;

/**
 * <p>
 * InvCheck实体，代表库存盘点表头。
 * </p>
 * 
 */
@Entity()
@Table(name = "I_CHECKHEADER")
@BatchSize(size=20)
@Lazy(value=true)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class InvCheck extends BasicModel{
	//唯一号
	@Id
	@GenericGenerator(name = "uniqueId", strategy = "assigned")
	@Column(name="UNIQUEID")
	protected String uniqueId;
	
	// 盘点单号
	@Column(name="INVCHECKID")
	protected String invCheckUid;
	
	// 出入库单据明细
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "invCheck")
	//@OrderBy(clause = "SEQ asc")
	private Set<InvCheckDetail> invCheckDetails;
	
	// 盘点日期
	@Column(name="INVCHECKDATE")
	protected Date invCheckDate;
	
	// 盘点类型
	@Column(name="INVCHECKTYPE")
	protected Integer invCheckType;
	
	// 盘点单状态
	@Column(name="INVCHECKSTATE")
	protected Integer invCheckState;
	
	// 库房编号
	@Column(name="WAREHOUSEID")
	protected String warehouseUid;
	
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="WAREHOUSEID",insertable=false,updatable=false)
	protected Warehouse warehouse;

	// 库管员编号
	@Column(name="WAREHOUSEMANAGER")
	protected String warehouseManagerUid;
	
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="WAREHOUSEMANAGER",insertable=false,updatable=false)
	protected Employee warehouseManager;
	
	// 账面金额
	@Column(name="ACCOUNTEDAMOUNT")
	protected Double accountedAmount;

	// 实盘金额
	@Column(name="ACTUALAMOUNT")
	protected Double actualAmount;
	
	// 审核者编号
	@Column(name="BILLCHECKER")
	protected String billCheckerUid;
	
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="BILLCHECKER",insertable=false,updatable=false)
	protected Employee billChecker;

	// 经办人编号
	@Column(name="TRANSACTOR")
	protected String transactorUid;
	
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="TRANSACTOR",insertable=false,updatable=false)
	protected Employee transactor;
	
	
	@Override
	public String getUuid() {
		// TODO Auto-generated method stub
		return this.getUniqueId();
	}

	@Override
	public void setUuid(String uuid) {
		// TODO Auto-generated method stub
		this.setUniqueId(uuid);
	}

	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}

	public String getInvCheckUid() {
		return invCheckUid;
	}

	public void setInvCheckUid(String invCheckUid) {
		this.invCheckUid = invCheckUid;
	}

	public Set<InvCheckDetail> getInvCheckDetails() {
		return invCheckDetails;
	}

	public void setInvCheckDetails(Set<InvCheckDetail> invCheckDetails) {
		this.invCheckDetails = invCheckDetails;
	}

	public Date getInvCheckDate() {
		return invCheckDate;
	}

	public void setInvCheckDate(Date invCheckDate) {
		this.invCheckDate = invCheckDate;
	}

	public Integer getInvCheckType() {
		return invCheckType;
	}

	public void setInvCheckType(Integer invCheckType) {
		this.invCheckType = invCheckType;
	}

	public Integer getInvCheckState() {
		return invCheckState;
	}

	public void setInvCheckState(Integer invCheckState) {
		this.invCheckState = invCheckState;
	}

	public String getWarehouseUid() {
		return warehouseUid;
	}

	public void setWarehouseUid(String warehouseUid) {
		this.warehouseUid = warehouseUid;
	}

	public Warehouse getWarehouse() {
		return warehouse;
	}

	public void setWarehouse(Warehouse warehouse) {
		this.warehouse = warehouse;
	}

	public String getWarehouseManagerUid() {
		return warehouseManagerUid;
	}

	public void setWarehouseManagerUid(String warehouseManagerUid) {
		this.warehouseManagerUid = warehouseManagerUid;
	}

	public Employee getWarehouseManager() {
		return warehouseManager;
	}

	public void setWarehouseManager(Employee warehouseManager) {
		this.warehouseManager = warehouseManager;
	}

	public Double getAccountedAmount() {
		return accountedAmount;
	}

	public void setAccountedAmount(Double accountedAmount) {
		this.accountedAmount = accountedAmount;
	}

	public Double getActualAmount() {
		return actualAmount;
	}

	public void setActualAmount(Double actualAmount) {
		this.actualAmount = actualAmount;
	}
	
	public String getBillCheckerUid() {
		return billCheckerUid;
	}

	public void setBillCheckerUid(String billCheckerUid) {
		this.billCheckerUid = billCheckerUid;
	}

	public Employee getBillChecker() {
		return billChecker;
	}

	public void setBillChecker(Employee billChecker) {
		this.billChecker = billChecker;
	}

	public String getTransactorUid() {
		return transactorUid;
	}

	public void setTransactorUid(String transactorUid) {
		this.transactorUid = transactorUid;
	}

	public Employee getTransactor() {
		return transactor;
	}

	public void setTransactor(Employee transactor) {
		this.transactor = transactor;
	}
}